#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#define int long long
#define x first 
#define y second 
using namespace std;
const int N = 1e3 + 10;
int a[N];
void solve()
{
/*     int ans = 0;
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    for(int i = 1; i <= n - 2; i++)
    {
        for(int j = i + 1; j <= n - 1; j++)
        {
            for(int k = j + 1; k <= n; k++)
            {
                if(a[i] + a[k] > a[j] && a[j] + a[i] > a[k] && a[k] + a[j] > a[i]) 
                {
                    ans += 1;
                }
            }
        }
    }
    cout << ans << endl; */
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)  cin >> a[i];
    sort(a, a + n);
    int cnt = 0;
    for(int k = 2; k < n; k++)
    {
        int i = 0;  int j = k - 1;
        while(i < j)
        {
            if(a[i] + a[j] > a[k])
            {
                cnt += (j - i);
                j--; 
            }
            else 
            {
                i++;
            }
        }
    }
    cout << cnt << endl;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    int t = 1;
    /*  int t;
     cin >> t; */
    while(t -- ) solve();
    return 0;
}